{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 阴阳"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "dotnet_interactive": {
     "language": "csharp"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    },
    "vscode": {
     "languageId": "polyglot-notebook"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><div></div><div></div><div><strong>Installed Packages</strong><ul><li><span>ConsoleTables, 2.6.1</span></li><li><span>YiJingFramework.PrimitiveTypes, 4.0.1</span></li></ul></div></div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#r \"nuget:ConsoleTables\"\n",
    "#r \"nuget:YiJingFramework.PrimitiveTypes\"\n",
    "using ConsoleTables;\n",
    "using YiJingFramework.PrimitiveTypes;"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "由于只存在两个可能的值，因此 `Yinyang` 与先前的[五行](./五行.ipynb)和[干支](./天干地支.ipynb)略有不同，内部是使用布尔值来表示的。对外它提供 `IsYang` 属性取得此值，也提供了相对应的构造方法。除此之外，它不支持加减运算，但是支持布尔类型所具有的 `!` 运算符，以及 `&` 、 `|` 和 `^` 运算。\n",
    "\n",
    "> 不过，我们不打算为它实现 `operator true` 和 `operator false` ，因为它本身并不是一个布尔值。\n",
    "\n",
    "这里主要显示一下其 `ToString` 的结果："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "dotnet_interactive": {
     "language": "csharp"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    },
    "vscode": {
     "languageId": "polyglot-notebook"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "| Yinyang      | G    | C  |\r\n",
      "|--------------|------|----|\r\n",
      "| Yinyang.Yin  | Yin  | 阴 |\r\n",
      "| Yinyang.Yang | Yang | 阳 |\r\n",
      "\r\n"
     ]
    }
   ],
   "source": [
    "var table = new ConsoleTable(\"Yinyang\", \"G\", \"C\");\n",
    "table.AddRow(\"Yinyang.Yin\", Yinyang.Yin.ToString(\"G\"), Yinyang.Yin.ToString(\"C\"));\n",
    "table.AddRow(\"Yinyang.Yang\", Yinyang.Yang.ToString(\"G\"), Yinyang.Yang.ToString(\"C\"));\n",
    "table.Write(Format.Minimal);"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "file_extension": ".cs",
   "mimetype": "text/x-csharp",
   "name": "python",
   "pygments_lexer": "csharp",
   "version": "3.12.2"
  },
  "polyglot_notebook": {
   "kernelInfo": {
    "defaultKernelName": "csharp",
    "items": [
     {
      "aliases": [],
      "name": "csharp"
     }
    ]
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
